package com.starview.star;

import com.starview.platform.data.type.Location;
import com.starview.star.compiler.ErrorReport;

/**
 * LanguageException is used when reporting something wrong with a StarRules compilation
 * 
 * @author fgm
 * 
 */
public class LanguageException extends Exception
{
  private static final long serialVersionUID = 1L;
  private final ErrorReport messages;

  public LanguageException(ErrorReport messages)
  {
    super(messages.toString());
    this.messages = messages;
  }

  public LanguageException(ErrorReport messages, String msg, Location... locs)
  {
    super(messages.toString());
    this.messages = messages;
    messages.reportError(msg, locs);
  }

  public LanguageException(String msg)
  {
    this(msg, Location.nullLoc);
  }

  public LanguageException(String msg, Location... locs)
  {
    super(msg);

    messages = new ErrorReport();
    messages.reportError(msg, locs);
  }

  public ErrorReport getMessages()
  {
    return messages;
  }

  @Override
  public String getMessage()
  {
    return messages.toString();
  }

}
